/*
 * $Id$
 */

package py.windmill.util;

/**
 *
 * @author py
 */
public abstract class Database {

    protected String _host;
    protected String _name;
    protected int _port;
    protected String _username;
    protected String _password;

    public static Database mysql() {
        return new Database() {
            @Override
            public String getJdbcUrl() {
                return new StringBuilder("jdbc:mysql://").append(_host)
                        .append(":").append(_port).append("/").append(_name)
                        .toString();
            }
            @Override
            public String getDriver() {
                return "com.mysql.jdbc.Driver";
            }
        };
    }

    public Database setHost(final String host) {
        _host = host;
        return this;
    }
    
    public Database setName(final String name) {
        _name = name;
        return this;
    }
    
    public Database setPort(final int port) {
        _port = port;
        return this;
    }
    
    public Database setUsername(final String username) {
        _username = username;
        return this;
    }
    
    public Database setPassword(final String password) {
        _password = password;
        return this;
    }

    public String getUsername() {
        return _username;
    }

    public String getPassword() {
        return _password;
    }
    
    public abstract String getJdbcUrl();

    public abstract String getDriver();
}
